#获取jenkins的基础镜像
FROM jenkins/jenkins

#制作者信息
MAINTAINER sydr sydr@juexiaotime.com

#指定docker容器运行时的用户
USER root

#安装vim、aptitude、git、axel（多线程下载）、jdk、allure、python、nox、ant、jemeter、jenkins文件参数所使用的library
COPY jmeter_ant/jenkinsci-unstashParam-library-master.zip /

RUN echo "deb http://mirrors.163.com/debian/ buster main non-free contrib \
	deb http://mirrors.163.com/debian/ buster-updates main non-free contrib \
	deb http://mirrors.163.com/debian/ buster-backports main non-free contrib \
	deb http://mirrors.163.com/debian-security/ buster/updates main non-free contrib \
	deb-src http://mirrors.163.com/debian/ buster main non-free contrib \
	deb-src http://mirrors.163.com/debian/ buster-updates main non-free contrib \
	deb-src http://mirrors.163.com/debian/ buster-backports main non-free contrib \
	deb-src http://mirrors.163.com/debian-security/ buster/updates main non-free contrib">/etc/apt/sources.list \
	&& apt-get update \
	&& apt-get -y install aptitude \
	&& aptitude  -y install vim \
	&& aptitude -y install git \
	&& aptitude -y install openjdk-11-jdk \
	&& aptitude -y install axel \
	&& axel -n 3 https://repo.maven.apache.org/maven2/io/qameta/allure/allure-commandline/2.13.2/allure-commandline-2.13.2.zip \
	&& unzip allure-commandline-2.13.2.zip \
	&& aptitude -y install build-essential zlib1g-dev libncurses5-dev libgdbm-dev libnss3-dev libssl-dev libreadline-dev libffi-dev libsqlite3-dev \
	&& wget  https://www.python.org/ftp/python/3.8.0/Python-3.8.0.tgz --no-check-certificate \
	&& tar -xf Python-3.8.0.tgz \
	&& mkdir /usr/local/python3.8 \
	&& cd Python-3.8.0 \
	&& ./configure --enable-optimizations --prefix=/usr/local/python3.8 \
	&& make && make install \
	&& rm -rf /usr/bin/python \
	&& rm -rf /usr/bin/python2.7 \
	&& rm -rf /usr/lib/python2.7 \
	&& rm -rf /etc/python \
	&& rm -rf /etc/python2.7 \
	&& rm -rf /usr/local/lib/python2.7 \
	&& rm -rf /usr/share/python \
	&& rm -rf /usr/share/man/man1/python.1.gz \
	&& ln -s /usr/local/python3.8/bin/python3.8  /usr/bin/python \
	&& cd /usr/local/python3.8/bin \
	&& ./pip3.8 install nox -i https://pypi.tuna.tsinghua.edu.cn/simple/ \
	&& cd / \
	&& axel -n 3 https://mirrors.bfsu.edu.cn/apache//ant/binaries/apache-ant-1.10.11-bin.zip \
	&& unzip apache-ant-1.10.11-bin.zip \
	&& axel -n 3 https://mirrors.bfsu.edu.cn/apache//jmeter/binaries/apache-jmeter-5.4.1.zip \
	&& unzip apache-jmeter-5.4.1.zip \
	&& mkdir /apache-jmeter-5.4.1/TestCases \
	&& mkdir /apache-jmeter-5.4.1/report \
	&& mkdir /apache-jmeter-5.4.1/report/jtl \
	&& mkdir /apache-jmeter-5.4.1/report/html \
	&& rm -rf /apache-jmeter-5.4.1/bin/jmeter.properties \
	&& cp /apache-jmeter-5.4.1/extras/ant-jmeter-1.1.1.jar /apache-ant-1.10.11/lib/ant-jmeter-1.1.1.jar \
	&& cp /apache-jmeter-5.4.1/lib/xalan-2.7.2.jar /apache-ant-1.10.11/lib/xalan-2.7.2.jar \
	&& cp /apache-jmeter-5.4.1/lib/serializer-2.7.2.jar /apache-ant-1.10.11/lib/serializer-2.7.2.jar \
	&& unzip jenkinsci-unstashParam-library-master.zip \
	&& cd /jenkinsci-unstashParam-library-master \
	&& git init \
    && git add . \
	&& git config --global user.email "sydr@juexiaotime.com" \
	&& git config --global user.name "sydr" \
	&& git commit -m "init" \
	&& git ls-remote -h /jenkinsci-unstashParam-library-master \
	&& echo "export PATH=/apache-jmeter-5.4.1/bin:/apache-ant-1.10.11/bin:/allure-2.13.2/bin:/usr/local/python3.8/bin:$PATH" >> /etc/profile \
	&& cd /tmp \
	&& touch cpa_log_rules \
	&& echo "warn /INFO:.*[\w/]+[\d.]$/" >cpa_log_rules \
    && echo "warn /WARNING:.*[\w/]+[\d.]$/">>cpa_log_rules \
    && cd /etc \
	&& mv localtime localtime_bak \
	&& cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \
	&& echo "Asia/shanghai" > /etc/timezone \
	&& echo "source /etc/profile">>/root/.bashrc
	
COPY jmeter_ant/jmeter.properties /apache-jmeter-5.4.1/bin/
COPY jmeter_ant/build.xml /apache-jmeter-5.4.1/
COPY jmeter_ant/jmeter.results.shanhe.me.xsl /apache-jmeter-5.4.1/extras/
COPY jmeter_ant/ext/ /apache-jmeter-5.4.1/lib/ext/